package cn.jh.common.utils;

public enum ChannelType {

    /** 商旅 */
    CHANNEL_TAG_04(1,"CHANPAYNEWCARD_04", "商旅04"),

    /** 新无卡101 */
    CHANNEL_TAG_0101(2,"CHANPAYNEWCARD_0101", "新无卡101"),

    /** 新无卡102 */
    CHANNEL_TAG_0102(3,"CHANPAYNEWCARD_0102", "新无卡102"),

    /** 商旅 */
    CHANNEL_TAG_05(4,"CHANPAYNEWCARD2_04", "商旅05"),

    /** 落地商户 */
    CHANPAYNEWCARD_1500(5,"CHANPAYNEWCARD_1500", "落地商户"),
    ;

    final int code;
    final String value;
    final String desc;

    ChannelType(int code, String value, String desc) {
        this.code = code;
        this.value = value;
        this.desc = desc;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public int getCode() {
        return code;
    }

    public static ChannelType of(int val) {
        return of(val, null);
    }

    public static ChannelType of(int val, ChannelType defaultStatus) {
        if (val == 0) {
            return defaultStatus;
        }

        for (ChannelType os : values()) {
            if (val == os.getCode()) {
                return os;
            }
        }
        return defaultStatus;
    }

}
